

using System;
using System.Text;

using NHibernate;
using NHibernate.Cfg;
using NHibernate.Criterion;
using NHibernate.Exceptions;

using LastFMGenNHibernate.EN.LastFM;
using LastFMGenNHibernate.CAD.LastFM;

namespace LastFMGenNHibernate.CEN.LastFM
{
        public partial class ArtistaCEN
        {
        private IArtistaCAD _IArtistaCAD;

        public ArtistaCEN(IArtistaCAD _IArtistaCAD)
        {
                this._IArtistaCAD = _IArtistaCAD;
        }

        public int New_ (int p_id, String p_etiqueta, System.Collections.Generic.IList<int> p_cancion, int p_grupo, String p_nombre, int p_valor)
        {
                ArtistaEN artistaEN = null;
                int oid;

                //Initialized ArtistaEN
                artistaEN = new ArtistaEN ();
                artistaEN.Id = p_id;
                artistaEN.Etiqueta = p_etiqueta;
                if (p_cancion != null) {
                        artistaEN.Cancion = new System.Collections.Generic.List<LastFMGenNHibernate.EN.LastFM.CancionEN>();
                        foreach (int item in p_cancion) {
                                LastFMGenNHibernate.EN.LastFM.CancionEN en = new LastFMGenNHibernate.EN.LastFM.CancionEN ();
                                en.Id = item;
                                artistaEN.Cancion.Add (en);
                        }
                }
                if (p_grupo != -1) {
                        artistaEN.Grupo = new LastFMGenNHibernate.EN.LastFM.GrupoEN ();
                        artistaEN.Grupo.Id = p_grupo;
                }
                artistaEN.Nombre = p_nombre;
                artistaEN.Valor = p_valor;
                //Call to ArtistaCAD

                oid = _IArtistaCAD.New_ (artistaEN);
                return oid;
        }

        public void Destroy (int id)
        {
                _IArtistaCAD.Destroy (
                        id

                        );
        }

        public void Modify (int p_Artista_OID, String p_etiqueta, String p_nombre, int p_valor)
        {
                ArtistaEN artistaEN = null;

                //Initialized ArtistaEN
                artistaEN = new ArtistaEN ();
                artistaEN.Id = p_Artista_OID;
                artistaEN.Etiqueta = p_etiqueta;
                artistaEN.Nombre = p_nombre;
                artistaEN.Valor = p_valor;
                //Call to ArtistaCAD

                _IArtistaCAD.Modify (artistaEN);
        }

        public System.Collections.Generic.IList<ArtistaEN> DevolverArtistas (int first, int size)
        {
                System.Collections.Generic.IList<ArtistaEN> list = null;

                list = _IArtistaCAD.DevolverArtistas (first, size);
                return list;
        }
        }
}
